/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package chat;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.Socket;
import java.net.UnknownHostException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Jeffom
 */
public class Cliente implements Runnable{
    Socket s;
    Pacote pack;
    String nome;
    ObjectInputStream in;
    ObjectOutputStream out;
    
    //Acessores    
    public Socket getSocket()
    {
        return s;
    }
    
    public void setPack(Pacote value)
    {
        pack = value;
    }
    
    public Pacote getPack()
    {
        return pack;
    }
    public void setNome(String value)
    {
        nome = value;
    }
    public String getNome()
    {
        return nome;
    }
    
    //Métodos
    public boolean Conectar(String ip, int porta) throws UnknownHostException, IOException
    {
        s = new Socket(ip,porta);
        if(s.isConnected())
            return true;
        else
            return false;
    }  
    
    public void Enviar() throws IOException
    {
        if(pack != null)
        {
            out = new ObjectOutputStream( s.getOutputStream() );
            out.writeObject(pack);
        }
    }

    public void run()
    {

     }
    
            
}
